<?php
class mjurisdiccion extends Model 
{
	private $mTableName='GN_Jurisdiccion';
	
	public function __construct()
	{
		parent::Model();
	}
	
	function createJurisdiccion($nombre)
	{
		
		$data=array('NombreJurisdiccion'=>$nombre);
		$this->db->insert($this->mTableName, $data);
		
	}
	
	function updateJurisdiccion($jurisdiccion,$id)
	{
		$data=array('NombreJurisdiccion'=>$jurisdiccion);
		$this->db->where('IdJurisdiccion',$id);
        	$this->db->update($this->mTableName, $data);
			
			return true;
	}
	
	
	
	function LoadjurisdiccionById($id_jurisdiccion) 
	{
		$qresult = $this->db->get_where($this->mTableName, array('IdJurisdiccion' => $id_jurisdiccion));		
		if ($qresult->num_rows() == 0)
				return false;

			return new obj_jurisdiccion($qresult->row());
	}
	
	function LoadJurisdiccion($name = false, $start = false, $offset = false, $sortname = false, $sortorder = false) 
	{
			if($name != false && $name != '')
				$this->db->like('NombreJurisdiccion', $name);
			
			if($offset != false)
				$this->db->limit($offset, $start);

			if($sortname != false && $sortorder != false) {
				$this->db->order_by($sortname, $sortorder);
			}
	
			$result = $this->db->get_where($this->mTableName);
	
			return $this->GetJurisdiccionArrayFromQueryResult($result);
		}
		
	function GetJurisdiccionArrayFromQueryResult($result) 
	{
			if ($result->num_rows() == 0)
				return false;
	
			$etapas_arr = array();
	
			foreach ($result->result() as $record) {
				$etapas_arr[] = new obj_jurisdiccion($record);
			}
	
			return $etapas_arr;
    }
    function GetCount() 
    {
		return count($this->LoadJurisdiccion());
	}
	
	function Delete($id_jurisdiccion) 
	{
		$return = $this->db->delete($this->mTableName, array('IdJurisdiccion' =>$id_jurisdiccion));
		return $return;
	}
    	
}


class obj_jurisdiccion
{
	private $idjurisdiccion;
	private $nombrejurisdiccion;
	
	public function __construct($obj)
	{
		$this->setIdJurisdiccion($obj->IdJurisdiccion);
		$this->setNombreJurisdiccion($obj->NombreJurisdiccion);
	}
	
	public function setIdJurisdiccion($idjurisdiccion)
	{
		$this->idjurisdiccion=$idjurisdiccion;
	}
	
	public function getIdJurisdiccion()
	{
		return $this->idjurisdiccion;
	}
	
	public function setNombreJurisdiccion($nombrejurisdiccion)
	{
		$this->nombrejurisdiccion=$nombrejurisdiccion;
	}
	
	public function getNombreJurisdiccion()
	{
		return $this->nombrejurisdiccion;
	}
}

?>